package toolkit;

import java.util.Collection;
import java.util.Iterator;

public class CollectionUtils
{
	@SuppressWarnings("unchecked")
	public static String join(Collection pieces, String delimeter)
	{
	    StringBuilder builder = new StringBuilder();
	    
	    Iterator iterator = pieces.iterator();
	    
	    while (iterator.hasNext())
	    {
	    	builder.append(iterator.next());
	    	
	    	if (iterator.hasNext())
	    	{
	    		builder.append(delimeter);
	    	}
	    }
	    
	    return builder.toString();
	}
}
